package com.example.search.model;

import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.io.Serializable;
import java.util.Date;

@Data
//动态es指定索引
@Document(indexName="post", type="post", createIndex=true)
public class PostDocment implements Serializable {

    @Id
    private Long id;

    // ik分词器  type=FieldType.Text表示该字段是一个文本   ik_smart：会对文本做最粗粒度的拆分，ik_max_word：会对文本做最细 力度的拆分
    @Field(type = FieldType.Text, searchAnalyzer="ik_smart", analyzer = "ik_max_word")
    private String title;
    //表示该字段是一个长整型
    @Field(type = FieldType.Long)
    private Long authorId;
    //表示该字段内容是一个文本并作为一个整体不可分
    @Field(type = FieldType.Keyword)
    private String authorName;
    private String authorAvatar;

    private Long categoryId;
    @Field(type = FieldType.Keyword)
    private String categoryName;

    private Integer level;
    private Boolean recomment;

    private Integer commentCount;
    private Integer viewCount;
    //表示该字段是一个文本日期类型，默认不建立索引
    @Field(type = FieldType.Date)
    private Date created;


}
